<?php
class IndexControl extends BaseControl{
	function indexAction(){
		
		$this->page_size = 10;
		
		$page = isset($_GET['page']) ? $_GET['page'] : 1;
		$page = is_numeric($page) ? ($page > 0 ? $page : 1) : 1;
		$page = ($page > 10) ? 10 : $page;
		$sql = "select id,title,url,seo_desc,content,up_time from article order by up_time desc";
		$array = M()->db->getRecordsByPage($page,$this->page_size,$sql);

		$pagecount = ($array['pageCount'] >= $this->pageDisplay) ? $this->pageDisplay : $array['pageCount']; 
		
		$this->out['pageCount'] = $pagecount;
		$this->out['page'] = $array['page'];
		$this->out['data'] = $array['data'];
		$this->out['href'] = DOMAIN;
		$this->out['pagestring'] = $this->fetch("page.html");
		//创建html缓存
		//$this->buildHtml('index.html',CACHE_PATH,'index.html');
		$this->display('list.html');
	}
	function articleAction(){
		
		$aurl = $_GET['aurl'];
		if(empty($aurl)){
			redirect('http://www.baidu.com/');
		}
		$article_model = D('article');
		$article_info = $article_model->getArticleInfo($aurl);
		$this->out['article_info'] = $article_info;
		$this->display('article.html');
	}
	function errorAction(){
		echo '404';
	}
	
}